home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
signal.arc
/
SAMPSI.C
< prev
next >
Wrap
Text File
|
1985-07-26
|
1KB
|
63 lines
#include <stdio.h>
#include <signal.h>
int brk = 0;
char *divstack;
int save0[2];
int save23[2];
ctlbrk()
{
brk = 1;
cputs("\r\n**BREAK**\r\n");
}
divzero()
{
char *p;
struct intinfo *p1;
struct intinfo2 p2;
p = (divstack + 100 - OFFSET_TO_REGS);
p1 = p;
peek(p1->Ss,p1->Sp,&p2,sizeof(struct intinfo2) );
printf("\r\n *** Divide by Zero at: %04x:%04x ***\r\n",
p2.Cs,p2.Ip);
poke(0,0,&save0,4);
poke(0,4*0x23,&save23,4);
exit(1);
}
main()
{
int i;
int j=0;
peek(0,0,&save0,4);
peek(0,4*0x23,&save23,4);
signal(ctlbrk,100,0x23);
divstack = signal(divzero,100,0x0);
for(i=0;! brk ;i++) {
printf("Num=%d\n",i);
}
brk = 0;
i=j/0; /* This should generate a divide by zero error */
/* Should never reach here..*/
printf("Woops\n");
}